/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2023. All rights reserved.
 * Description: hiudk_wq_intf.c
 * Author: -
 * Create:
 */

#include "ossl_knl.h"
#include "hiudk3.h"
#include "hiudk_internal.h"
int hiudk_wq_create(void *udkdev, struct hinic3_wq *wq, u32 q_depth, u16 wqebb_size)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(udkdev == NULL)) {
        pr_err("udkdev is NULL! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->wq_ops.hiudk_wq_create != NULL))) {
        return ops->wq_ops.hiudk_wq_create(sdk_hwdev, wq, q_depth, wqebb_size);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_wq_create);

void hiudk_wq_destroy(void *udkdev, struct hinic3_wq *wq)
{
    struct hiudk_ops *ops = NULL;

    if (unlikely(udkdev == NULL)) {
        pr_err("udkdev is NULL! \n");
        return;
    }

    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->wq_ops.hiudk_wq_destroy != NULL))) {
        return ops->wq_ops.hiudk_wq_destroy(wq);
    }
    pr_err("ops is NULL! \n");
    return;
}

EXPORT_SYMBOL(hiudk_wq_destroy);
